﻿<!DOCTYPE html>
<html>
<head>
	<title>小跳蛙快递驿站服务平台</title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<link href="../../backend/css/normalize.css" type="text/css" rel="stylesheet" />
	<link href="../../backend/css/main.css" type="text/css" rel="stylesheet" />
	<script src="../../backend/js/jquery.min.js" type="text/javascript"></script>
	<script src="../../backend/js/notice.js"  type="text/javascript"></script>
	<script src="../../backend/js/common.js" type="text/javascript"></script>
	<script src="../../backend/layer/layer.js"></script>
</head>
<body>
	<div class="content">
		<div class="top autoH">
			<div class="logo autoH">
				<img src="../../backend/images/logo.png" width="100%">
			</div>
		</div>
		<div class="middle">
			<form id="theForm">
				<div class="forminput">
					<input type="text" id="expressNum" name="expressNum" placeholder="请输入快递单号...">
					<input id="PageContext" type="hidden" value="${pageContext.request.contextPath}" />
					<div class="submBtn"></div>
				</div>
			</form>
		</div>
		<div class="funContdiv">
			<div class="funCont">
				<div class="userFun">
					<p class="funIcon userFunColor1"></p>
					<p class="funTxt">个人中心</p>
				</div>
<!--				<div class="userFun">-->
<!--					<p class="funIcon userFunColor2"></p>-->
<!--					<p class="funTxt">懒人排行</p>-->
<!--				</div>-->
<!--				<div class="userFun">-->
<!--					<p class="funIcon userFunColor3"></p>-->
<!--					<p class="funTxt">取货二维码</p>-->
<!--				</div>-->
				<div class="userFun">
					<p class="funIcon userFunColor4"></p>
					<p class="funTxt">我的快件</p>
				</div>
<!--快递助手是快递员可以看到的内容 所以如果是用户登录 则隐藏此图标-->
					<div class="userFun" id="userFun5">
						<p class="funIcon userFunColor5"></p>
						<p class="funTxt">快递助手</p>
					</div>
					<div class="userFun">
						<p class="funIcon userFunColor6"></p>
						<p class="funTxt">退出登录</p>
					</div>
			</div>
		</div>
	
		<div class="footer">
			<p class="copytxt">&copy;小跳蛙快递驿站</p>
		</div>
	</div>
	<script type="text/javascript">
	var isUser;
	var userPhone;
	$(function(){
		$.getJSON("/wx/userInfo.do",null,function(data){
			// 用户登录
			if (data.status == 1) {
				isUser = true;
				$("#userFun5").hide();
				layer.msg("亲爱的用户，欢迎进入小跳蛙快递e栈！");
			}
			// 快递员登录
			else{
				isUser = false;
				layer.msg("可爱的快递员，欢迎您进入小跳蛙快递e栈！");
			}
		});
	});

	$(function(){
		var pageContextVal = $("#PageContext").val();

		$(".userFun").click(function(){
			var clickNum = $(this).index();
			switch(clickNum){
				//个人中心
				case(0): 
					window.location.href= "/front/view/wxUserhome.html";
					break;
				// //懒人排行
				// case(1):
				// 	window.location.href= "/front/view/lazyboard.html";
				// 	break;
				// //取货二维码
				// case(2): window.location.href= "/wx/createQRCode.do?type=user"; break;
				//我的快件
				case(1): window.location.href= "/front/view/expressList.html"; break;
				//快递助手
				case(2): window.location.href= "/front/view/expressAssist.html"; break;
				//退出登录 跳转到登陆页面
				case(3):
					//1.	告知服务器
						$.getJSON("/wx/logout.do",function(data){
							if(data==='success'){
								layer.msg('您已成功退出,即将跳转至登录页');
							}
							setTimeout(function(){
								window.location.href="/front/view/login.html";
							},300)
						});
					break;
			}
		});

		var initFunc = function(){
			var windowH = $(document).height();
			var windowW = $(document).width();

			$(".content").css({"height": windowH+"px"});

			var contentW = $(".content").width();
			var contentH = $(".content").height();

			var contH = windowH / 3;
			$(".autoH").css({"height": contH+"px"});

			// userFunH  content
			var middleH = $(".middle").height() + 40;
			var userFunH = contentH - contH - middleH - 30 -20; //footer,userfun(margin)
			$(".funContdiv").css({"height":userFunH+"px"});

			var funIconH = $(".funIcon").width(); 
			$(".funIcon").css({"height": funIconH+"px","line-height": funIconH+"px","border-radius": funIconH/2 +"px","font-size":funIconH/2 +"px"});

		};

		initFunc();

		$(window).resize(function(){
			initFunc();
		});

		// input focus
		$(".middle .forminput input").focus(function(){
			$(".middle .forminput").css({"border":"1px solid rgba(31,114,255,.75)","box-shadow":"0 0 8px rgba(31,114,255,.5)"});
		});

		// input blur
		$(".middle .forminput input").blur(function(){
			$(".middle .forminput").css({"border":"1px solid #333333","box-shadow":"none"});
		});

		// 提交搜索
		$(".submBtn").click(function(){
			var expressNum = $("#expressNum").val();//快递单号
			console.log(expressNum);
			 $.ajax({
				    // type:'GET',
				    type:"post",
				    url:'/wx/indexQueryExpress.do',
				    data:{'expressNum':expressNum},
				    dataType: "json",
				    success:function(data){
						if (data.status === 1) {
							// 保存后端的数据
							var name = "收货人：" + data.data.name
							var phone = "手机号：" + data.data.phone
							var companyName = "快递公司：" + data.data.companyName
							var code = "取件码：" + data.data.code
							if (data.data.status === 1) {
								var status = "快递状态：待付款"
							}
							if (data.data.status === 2) {
								var status = "快递状态：待派送"
							}
							if (data.data.status === 3) {
								var status = "快递状态：待取件"
							}
							if (data.data.status === 4) {
								var status = "快递状态：已完成"
							}
							if (data.data.status === 5) {
								var status = "快递状态：已取消"
							}
							$("#name").val(name);
							$("#phone").val(phone);
							$("#company").val(companyName)
							$("#code").val(code)
							$("#status").val(status)
							if (data.data.status == 3)
								layer.msg(
										"<h2 style='text-align: center;'>快递信息</h2><hr/>" +
										"<h5 id='name'></h5>" + name +
										"<h5 id='phone'></h5>" + phone +
										"<h5 id='company'></h5>" + companyName +
										"<h5 id='code'></h5>" + code +
										"<h5 id='status'></h5>" + status,{time:5000});
							else
								layer.msg(
										"<h2 style='text-align: center;'>快递信息</h2><hr/>" +
										"<h5 id='name'></h5>" + name +
										"<h5 id='phone'></h5>" + phone +
										"<h5 id='company'></h5>" + companyName +
										"<h5 id='status'></h5>" + status,{time:5000});
						}
						else {
							layer.msg("<h2 style='text-align: center;'>快递信息</h2><hr/>" + "未查询到该快递！",{time:5000});
						}
				    }
				});
		});
	});
	</script>
</body>
</html>